package com.zyp.common.message.manager.impl;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

/**
 * @description: 设置消息超时时间
 * @author: zhenqiang.zhan
 * @create: 2018-11-17 14:35
 **/
public class ExpirationMessagePostProcessor implements MessagePostProcessor {

    private Long ttl;

    public ExpirationMessagePostProcessor(Long ttl) {
        this.ttl = ttl;
    }

    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().setExpiration(ttl.toString());
        return message;
    }
}
